package com.hpeu_01.day0125.hemowork;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * 第一题：客户端给服务端发送文本，服务端会将文本转成大写在返回给客户
 */
//服务端
public class Server {
    public static void main(String[] args) {
        try {
            ServerSocket ss = new ServerSocket(6666);
            Socket accept = ss.accept();
            InputStream is = accept.getInputStream();
            byte[] b = new byte[1024];
            int len = is.read(b);
            String s = new String(b, 0, len);
            String str = s.toUpperCase();

            OutputStream os = accept.getOutputStream();
            os.write(str.getBytes());

            os.close();
            is.close();
            accept.close();
            ss.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
